//
//  BaseViewController.m
//  BaseLib
//
//  Created by CPX on 2018/5/21.
//  Copyright © 2018年 CPX. All rights reserved.
//

#import "BaseViewController.h"
#import "Global.h"
#import "YYCategories.h"

/**
 基类控制器，废弃，不推荐使用
 @author yzl
 */
@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppLayoutDirectionSettingChanged:) name:@"direction_layout_change" object:nil];
    self.view.backgroundColor = [UIColor whiteColor];
    if (@available(iOS 11.0,*)) {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    //默认字体和颜色
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
}

- (void)initLeftBackNaviButton{
    self.myNavigationBar = [MyNavigationBar new];
    [self.myNavigationBar.backButton addTarget:self action:@selector(onLeftButtonTouched) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.myNavigationBar];
}

- (void)onLeftButtonTouched{
    if (self.navigationController && self.navigationController.viewControllers.count > 1) {
        [self.navigationController popViewControllerAnimated:YES];
    }
}

// 默认返回为YES,表示支持右滑返回
- (BOOL)gestureRecognizerShouldBegin{
    return YES;
}

- (void)handleError:(NSError *)error{
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)onAppLayoutDirectionSettingChanged:(NSNotification *)notification{
    
}

- (void)onAppLightModeChanged:(NSNotification *)notification{
    
}

- (void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}


@end
